package com.purong.purong.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.purong.purong.R;


/**
 * Created by Administrator on 2016/8/4.
 */
public class LocationDialog extends Dialog{
    private Context mContext;
    private OnConfirmClickListenr mListener;
    private String msg;
    public LocationDialog(Context context, String msg, OnConfirmClickListenr listenr) {
        super(context, R.style.DialogTransparent);
        this.mContext=context;
        this.mListener=listenr;
        this.msg=msg;
        setCanceledOnTouchOutside(false);
        getWindow().setWindowAnimations(R.style.dialogZoomStyle);

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View inflate = LayoutInflater.from(mContext).inflate(R.layout.dialog_location, null);
        setContentView(inflate);
        if (msg!=null)
        ((TextView)findViewById(R.id.msg)).setText(msg);
       findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               dismiss();
               if (mListener!=null){
                   mListener.onCancel();
               }
           }
       });
        findViewById(R.id.confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mListener!=null){
                    mListener.onConfirm();
                }
            }
        });
    }
    public interface OnConfirmClickListenr{
        void onConfirm();
        void onCancel();
    }
}
